{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "955ce3dd",
   "metadata": {},
   "source": [
    "# Plasma beta in the solar atmosphere"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c740ee3",
   "metadata": {},
   "source": [
    "\n",
    "This notebook demonstrates [plasmapy.formulary](https://docs.plasmapy.org/en/stable/formulary/index.html) by calculating plasma $β$ in different regions of the solar atmosphere."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f24a4eeb",
   "metadata": {},
   "source": [
    "## Contents"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e87ef2d",
   "metadata": {},
   "source": [
    "1. [Introduction](#Introduction)\n",
    "2. [Solar corona](#Solar-corona)\n",
    "3. [Solar chromosphere](#Solar-chromosphere)\n",
    "4. [Quiet solar photosphere](#Quiet-solar-photosphere)\n",
    "5. [Sunspot photosphere](#Sunspot-photosphere)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d5b71af4",
   "metadata": {},
   "source": [
    "## Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1bb15c25",
   "metadata": {},
   "source": [
    "[Plasma beta]: https://en.wikipedia.org/wiki/Beta_(plasma_physics)\n",
    "\n",
    "[Plasma beta] ($β$) is one of the most fundamental plasma parameters. $β$ is the ratio of the thermal plasma pressure to the magnetic pressure:\n",
    "\n",
    "$$β = \\frac{p_{therm}}{p_{mag}}.$$\n",
    "\n",
    "How a plasma behaves depends strongly on $β$. When $β ≫ 1$, the magnetic field is not strong enough to significantly alter the dynamics, so the plasma motion is more gas-like. When $β ≪ 1$, magnetic tension and magnetic pressure dominate the dynamics. \n",
    "\n",
    "Let's use [plasmapy.formulary.beta](https://docs.plasmapy.org/en/stable/api/plasmapy.formulary.dimensionless.beta.html#plasmapy.formulary.dimensionless.beta) to compare $β$ in different parts of the solar atmosphere."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47720605",
   "metadata": {},
   "outputs": [],
   "source": [
    "import astropy.units as u\n",
    "\n",
    "from plasmapy.formulary import beta"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24162ca9",
   "metadata": {},
   "source": [
    "## Solar corona"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60aa77b5",
   "metadata": {},
   "source": [
    "Let's start by defining some plasma parameters for an active region in the solar corona."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c4b98f58",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_corona = 1 * u.MK\n",
    "n_corona = 1e9 * u.cm**-3\n",
    "B_corona = 50 * u.G"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdc0c334",
   "metadata": {},
   "source": [
    "When we use these parameters in [beta](https://docs.plasmapy.org/en/stable/api/plasmapy.formulary.dimensionless.beta.html#plasmapy.formulary.dimensionless.beta), we find that $β$ is quite small which implies that the corona is magnetically dominated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "98b23229",
   "metadata": {},
   "outputs": [],
   "source": [
    "beta(T_corona, n_corona, B_corona)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68439232",
   "metadata": {},
   "source": [
    "## Solar chromosphere"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "42d4e729",
   "metadata": {},
   "source": [
    "Next let's calculate $β$ for the chromosphere. [Bogod et al. (2015)](https://doi.org/10.1007/s11207-014-0526-6) found that the quiet chromosphere ranges from ∼40–200 G.  We can get the temperature and number density of hydrogen from model C7 of [Avrett & Loeser (2007)](https://doi.org/10.1086/523671) for 1 Mm above the photosphere."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9f15627b",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_chromosphere = 6225 * u.K\n",
    "n_chromosphere = 2.711e13 * u.cm**-3\n",
    "B_chromosphere = [40, 200] * u.G"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "980fed87",
   "metadata": {},
   "outputs": [],
   "source": [
    "beta(T_chromosphere, n_chromosphere, B_chromosphere)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3dbc7da",
   "metadata": {},
   "source": [
    "When $B$ is small, plasma $β$ is not too far from 1, which means that both magnetic and plasma pressure gradient forces are important when the chromospheric magnetic field is relatively weak. When near the higher range of $B$, $β$ is small so that the magnetic forces are more important than plasma pressure gradient forces."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb163059",
   "metadata": {},
   "source": [
    "## Quiet solar photosphere"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "622e79fb",
   "metadata": {},
   "source": [
    "Let's specify some characteristic plasma parameters for the solar photosphere."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dde04a5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_photosphere = 5800 * u.K\n",
    "n_photosphere = 1e17 * u.cm**-3\n",
    "B_photosphere = 400 * u.G"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ba578e6",
   "metadata": {},
   "source": [
    "When we calculate β for the photosphere, we find that it is an order of magnitude larger than 1, so plasma pressure gradient forces are more important than magnetic forces."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5783b30",
   "metadata": {},
   "outputs": [],
   "source": [
    "beta(T_photosphere, n_photosphere, B_photosphere)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a511f72",
   "metadata": {},
   "source": [
    "## Sunspot photosphere"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e97e0c8",
   "metadata": {},
   "source": [
    "The magnetic field in the solar photosphere is strongest in sunspots, so we would expect β to be lowest there. Let's estimate some plasma parameters for a sunspot."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b230962",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_sunspot = 4500 * u.K\n",
    "B_sunspot = 2 * u.kG"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "809bed49",
   "metadata": {},
   "source": [
    "When we calculate β, we find that both pressure gradient and magnetic forces will be important."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9824ec24",
   "metadata": {},
   "outputs": [],
   "source": [
    "beta(T_sunspot, n_photosphere, B_sunspot)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
